<template>
  <div o-Container>
    <div class="content_left_box">
      <div class="top_box">
        <div class="search_box">
          <img
            src="/static/skin/herodoo/main/platform/home/img/search.png"
            alt=""
          />
          <input
            v-model="searchValue"
            type="text"
            placeholder="请输入搜索内容"
            @keydown.enter="searchEnterKeyPress"
            @blur="searchEnterKeyPress"
          />
          <!-- <img src="/static/skin/herodoo/main/platform/home/img/shaixuan.png" alt="" @click="openScreen()"> -->
        </div>
        <!-- <div class="button_box">
          <button>导出订单</button>
        </div> -->
      </div>
    </div>
    <!-- created: create, -->
    <!-- v-bind="{ exported: output }" -->
    <o-list v-bind:source="list.contract" v-bind="{ exported: output }">
      <template slot="config" slot-scope="scope">
        <div class="img_box">
          <img
            @click="showLookDiaolog(scope)"
            src="/static/skin/default/MCS/AIGC/Inventory/images/chakan.png"
            alt=""
          />
        </div>
      </template>
    </o-list>
    <SalesOrderMsg
      ref="salesOrderMsg"
      :messageList="messageList"
      @refresh="refresh"
    ></SalesOrderMsg>
    <screenRights ref="screenRights" @searchFun="search"></screenRights>
  </div>
</template>

<script>
import SalesOrderMsg from "../Components/SalesOrderMsg.vue";
import screenRights from "../Components/screenRights.vue";
export default {
  components: {
    SalesOrderMsg,
    screenRights
  },
  name:
    "mms_platform_company_list" /* 这个name暂时不知道用啥用，根据官方文档说的是方便排错的 */,
  data() {
    return {
      octopus: this.$parent.octopus,
      list: {
        contract: {
          data: {
            id: 76, // 菜单表的八爪鱼ID
            cellData: [
              // { name: "ChannelID" },	// 购买渠道
              { name: "Code", width: 200 }, // 订单编号
              { name: "Name", width: 400 }, // 权益名称
              { name: "Quantity" }, // 购买数量
              { name: "PurchaseCompanyName" }, // 卖家
              { name: "CompanyID", width: 200, show: false }, // 卖家
              { name: "ServiceCompanyName", width: 200 }, // 服务方
              { name: "ID", show: false }, // ID
              { name: "MerchantID", show: false }, // 买家的公司ID
              { name: "PurchaserID", show: false }, // 买家
              { name: "STATUS" }, // 订单状态
              { name: "STATUSID", show: false }, // StatusID
              { name: "TotalPrice" }, // 下单金额
              { name: "CreateTime", width: 150 }, // 下单时间
              { name: "ProductName", show: false }, // 产品名称
              { name: "PlatformID", show: false }, // 购买渠道
              { name: "PlatformIDName", show: false }, // 购买渠道
              { name: "CostPrice", show: false }, // 平台价格
              { name: "EquityID", show: false }, // 权益ID
              { name: "TypeID", show: false }, // TypeID
              { name: "UserPayTotalPrice" }, // 订单支付金额
              { name: "MerchantID", show: false }, // 买家

              { name: "Contact" , show: false}, // 联系人
              { name: "Integration", show: false }, // 使用积分
              { name: "MerchantIDName", show: false }, // 买家名称
              { name: "Mobile" , show: false}, // 手机
              { name: "ProductFlagList" , show: false}, // 产品标签
              { name: "ProductFlagListName" , show: false}, // 产品标签名称
              { name: "PurchaseID" , show: false}, // PurchaseID
              { name: "PurchaserCompanyID" , show: false}, // 买家ID
              { name: "RefundAmount" , show: false}, // RefundAmount
              { name: "RefundChannel" , show: false}, // RefundChannel
              { name: "RefundReasons", show: false }, // RefundReasons
              { name: "RefundTime" , show: false}, // RefundTime
              { name: "Remarks" , show: false}, // 备注
              { name: "TotalPrice", show: false }, // 下单金额(元)
              { name: "TradeTypeID", show: false }, // 交易方式
              {name: "OrderTime", show: false },	// OrderTime
              {name: "RefundQuantity", show: false },	// RefundQuantity
              {name: "ServiceCharge", show: false },	// ServiceCharge
            ],
            paramData: {}
          },
          configWidth: 35,
          showNumber: true
        }
      },
      repetition: true,
      messageList: {},
      messageListAdd: {},
      rightList: []
    };
  },
  created() {
    this.init();
  },
  methods: {
    init() {
      const data = this.list.contract.data;
      let company = this.octopus.passport.authorization.company;
      data.paramData.CompanyID = company == 1 ? "NULL" : company;
    },
    showLookDiaolog(row) {
      this.messageList = row.data.row;
      this.$nextTick(() => {
        // this.$refs.salesOrderMsg.pageShow = 0;
        this.$refs.salesOrderMsg.drawerOp();
      });
    },
    output: function(data) {
      this.octopus.tips.success("下载完成。");
    },
    search: function(cell) {},
    save: function(data) {
      // 保存
      this.octopus.tips.success(data);
      // 刷新list
      this.list.contract.control.load();
      this.back();
    },
    back: function() {
      this.panel.visible = false;
    },
    del: function(row) {
      let o = this;
      // alert("del key: " + JSON.stringify(row));
      this.$confirm("此操作将永久删除该项, 是否继续?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      })
        .then(() => {
          this.octopus.request.api.post(
            "/Octopus/Engine/Item",
            {
              id: 1188, // 菜单表的八爪鱼ID
              type: "DELETE",
              value: row.ID,
              cellData: [{ name: "ID", defaultValue: row.ID }]
            },
            // 处理回调事件，通过分析data.status.code的状态来实现。
            function(data) {
              if (data.status.code === 200) {
                o.list.contract.control.load();
              } else {
                o.octopus.tips.error(data);
              }
            }
          );
          this.$message({
            type: "success",
            message: "删除成功!"
          });
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: "已取消删除"
          });
        });
    },
    refresh() {
      this.list.contract.control.load();
    },
    openScreen() {
      this.$refs.screenRights.drawerOp();
    },
    searchEnterKeyPress(e) {
      this.list.contract.data.cellData[0] = {
        name: "Code",
        width: 200,
        filterKey: "like",
        filterValue: this.searchValue
      };
      this.list.contract.control.load();
    }
  },
  props: ["oData"]
};
</script>
<style scoped>
@import url("../../../../../../static/skin/default/MMS/AIGC/css/base.css");

.el-message-box {
  background-color: #fff !important;
}

.img_box {
  display: flex;
  justify-content: space-between;
  width: 100%;
}

.img_box img {
  width: 25px;
  cursor: pointer;
}
>>> .Operation {
  position: absolute;
  top: 1.5rem;
  left: 36rem;
}
>>> .Content {
  height: 84vh !important;
}
</style>
